app.controller('GetOneelectricdataCtrl',function ($scope,$http,$localStorage,$location,$window,$state,$interval) {
	$scope.namedata = $localStorage.cur_user.uname;	

  $scope.getdetail = function(){
    $http.post(
        $scope.app.backendurl+"tbl-electricity/view-one",
        {    
            
            'room_id':$state.params.roomid,
            'token':$localStorage.token                  

        }
      ).success(function (data) {
        console.log(data);
        if(data.code==0&&data.msg=="读取成功"){             
          $scope.aaData = data.data.model;                
        }
        if(data.code==1){             
          alert(data.msg)
                
        }
        if(data.code==20001&&data.msg=='请先登录'){
          $location.path('access.signin');
        }  
    
   
    }).error(function(data){
      console.log(data);
    })

  }
	
  var timer1,timer2,timer3;
  $scope.setinterval1 = function(){    
    $interval.cancel(timer2);
    $interval.cancel(timer3);
    timer1 = $interval($scope.getdetail,30*1000)
  }
  $scope.setinterval2 = function(){
    $interval.cancel(timer1); 
    $interval.cancel(timer3);
    timer2 = $interval($scope.getdetail,60*1000)   
  }
  $scope.setinterval3 = function(){ 
    $interval.cancel(timer1);
    $interval.cancel(timer2);
    timer3 = $interval($scope.getdetail,300*1000)
  }
  $scope.getdetail();

  $scope.$on("$destroy", function() {        
    $interval.cancel(timer1);
    $interval.cancel(timer2);
    $interval.cancel(timer3);
       
  });
 



})